$795 for the plain version, $1295 for the ``developer's''
version.
Over the years,
Ashton-Tate became a stodgy bureaucracy. George Tate died, Wayne
Ratliff quit, the company's list price for DBASE grew
ridiculously high, and the company was callous to DBASE users.
In 1991, Borland bought
Ashton-Tate. In 1994, Borland began selling DBASE 5. Discount
dealers sell it for $529.
Dramatic improvements to
DBASE have been created by other companies, who make clones of
DBASE that outshine DBASE itself! The most popular clone is
FOXPRO 2.6, which runs faster than DBASE, includes extra
commands, and is marketed by Microsoft. Discount dealers have
been selling it for just $94, but that temporary low price will
probably rise.
IF & PICK
LOOP
PREPARE & DATA
HOW
Here's how to use them. . . .
SAY EASY uses the word SAY instead of BASIC's word PRINT,
because SAY is briefer. If you want the computer to say the
answer to 2+2, give this command:
SAY 2+2
The computer will say the answer:
4
Whenever the computer prints, it automatically prints a blank
space afterwards but does not press the ENTER key. So if you run
this program ___
SAY "LOVE"
SAY "HATE"
the computer will say:
LOVE HATE
Here's a fancier example:
SAY "LOVE" AS 3 AT 20 15 TRIM !
The ``AS 3'' is a format: it makes the computer print just the
first 3 letters of LOVE. The ``AT 20 15'' makes the computer
begin printing LOVE at the screen's pixel whose X coordinate is
20 and whose Y coordinate is 15. The computer usually prints a
blank space after everything, but the word TRIM suppresses that
blank space. The exclamation point makes the computer press the
ENTER key afterwards.
Here's another example:
SAY TO SCREEN PRINTER HARRY
It means that henceforth, whenever you give a SAY command, the
computer will print the answer simultaneously onto your screen,
onto your printer, and onto a disk file named HARRY. If you ever
want to cancel that ``SAY TO'' command, give a ``SAY TO'' command
that contradicts it.
GET EASY uses the word GET instead of BASIC's word INPUT,
because GET is briefer. The command GET X makes the computer wait
for you to input the value of X. Above the GET command, you
typically put a SAY command that makes the computer ask a
question.
You can make the GET command fancy, like this:
GET X AS 3 AT 20 15 WAIT 5
The ``AS 3'' tells the computer that X will be just 3 characters;
the computer waits for you to type just 3 characters and doesn't
require you to press the ENTER key afterwards. The ``AT 20 15''
makes the computer move to pixel 20 15 before your typing begins,
so your input appears at that part of the screen. The ``WAIT 5''
makes the computer wait just 5 seconds for your response. If you
reply within 5 seconds, the computer sets TIME equal to how many
seconds you took. If you do not reply within the 5 seconds, the
computer sets TIME equal to -1.
LET The LET statement
resembles BASIC's. For example, you can say:
LET R=4
To let R be a random
decimal, type:
LET R=RANDOM
To let R be a random integer from 1 to 6, type:
LET R=RANDOM TO 6
To let R be a random integer from -3 to 5, type:
LET R=RANDOM FROM -3 TO 5
REPEAT If you put the
word REPEAT at the bottom of your program, the computer will
repeat the entire program again and again, forming an infinite
loop.
SKIP If you put the word
SKIP in the middle of your program, the computer will skip the
bottom part of the program. SKIP is like BASIC's END or STOP.
HERE In the middle of
your program, you can say:
HERE IS FRED
An earlier line can say SKIP TO FRED. A later line can say REPEAT
FROM FRED. The SKIP TO and REPEAT FROM are like BASIC's GO TO.
IF In your program, a
line can say:
IF X<3
Underneath that line, you must put some indented lines, which the
computer will do if X<3.
Suppose you give a
student a test on which the score can be between 0 and 100. If
the student's score is 100, let's make the computer say
``PERFECT''; if the score is below 100 but at least 70, let's
make the computer say the score and also say ``OKAY THOUGH NOT
PERFECT''; if the score is below 70, let's make the computer say
``YOU FAILED''. Here's how:
IF SCORE=100
SAY "PERFECT"
IF SCORE<100 AND SCORE>=70
SAY SCORE
SAY "OKAY THOUGH NOT PERFECT"
IF SCORE<70
SAY "YOU FAILED"
To shorten the program,
use the words NOT and BUT:
IF SCORE=100
SAY "PERFECT"
IF NOT BUT SCORE>=70
SAY SCORE
SAY "OKAY THOUGH NOT PERFECT"
IF NOT
SAY "YOU FAILED"
The phrase ``IF NOT'' is like BASIC's ELSE. The phrase ``IF NOT
BUT'' is like BASIC's ELSE IF.
PICK You can shorten
that example even further, by telling the computer to pick just
the first IF that's true:
PICK SCORE
IF 100
SAY "PERFECT"
IF >=70
SAY SCORE
SAY "OKAY THOUGH NOT PERFECT"
IF NOT
SAY "YOU FAILED"
LOOP If you put the word LOOP above indented lines, the
computer will do those lines repeatedly. For example, this
program makes the computer say the words CAT and DOG repeatedly:
LOOP
SAY "CAT"
SAY "DOG"
This program makes the computer say 5, 8, 11, 14, and 17:
LOOP I FROM 5 BY 3 TO 17
SAY I
That LOOP statement is like BASIC's ``FOR I = 5 TO 17 STEP 3''.
If you omit the ``BY 3'', the computer will assume ``BY 1''. If
you omit the ``FROM 5'', the computer will assume ``FROM 1''. If
you omit the ``TO 17'', the computer will assume ``to infinity''.
To make the computer count down instead of up, insert the word
DOWN, like this:
LOOP I FROM 17 DOWN BY 3 TO 5
PREPARE To do an unusual activity, you should PREPARE the
computer for it. For example, if you want to use subscripted
variables such as X(100), you should tell the computer:
PREPARE X(100)
In that example, PREPARE is like BASIC's DIM.
DATA EASY's DATA statement resembles BASIC's. But instead of
saying READ X, say:
LET X=NEXT
HOW In EASY, you can give any command you wish, such as:
PRETEND YOU ARE HUMAN
If you give that command, you must also give an explanation that
begins with the words:
HOW TO PRETEND YOU ARE HUMAN
Interrelated features In
the middle of a loop, you can abort the loop. To skip out of the
loop (and progress to the rest of the program), say SKIP LOOP. To
hop back to the beginning of the loop (to do the next iteration
of loop), say REPEAT LOOP.
Similarly, you can say
SKIP IF (which makes the computer skip out of an IF) and REPEAT
IF (which makes the computer repeat the IF statement, and thereby
imitate PASCAL's WHILE).
Apostrophe Like BASIC,
EASY uses an apostrophe to begin a comment. The computer ignores
everything to the right of an apostrophe, unless the apostrophe
is between quotation marks or in a DATA statement.
Comma If two statements
begin with the same word, you can combine them into a single
statement, by using a comma.
For example, instead of
saying ___
LET X=4
LET Y=7
you can say:
LET X=4, Y=7
Instead of saying ___
PRETEND YOU ARE HUMAN
PRETEND GOD IS DEAD
you can say:
PRETEND YOU ARE HUMAN, GOD IS DEAD
More info I stopped
working on EASY in 1982, but I expect to continue development
again soon. To get on my mailing list of people who want more
details and updated information about EASY, phone me at
617-666-2666 or send me a postcard.
EASYEASY is a language I developed several years ago. It combines the best features of all other languages. It's easy to learn, because it uses just these twelve keywords:SAY & GETLETREPEAT & SKIPHERE
RADICALS
Let's examine the radical languages, beginning with the oldest
radical ___ the oldest hippie ___ LISP.
LISP
LISP is the only language made specifically to handle lists of
concepts. It's the most popular language for research into
artificial intelligence.
It's the father of LOGO, which is ``oversimplified LISP'' and
the most popular language for young children. It inspired PROLOG,
which is a LISP-like language that lets you make the computer
imitate a wise expert and become an expert system.
Beginners in artificial intelligence love to play with LOGO and
PROLOG, which are easier and more fun than LISP. But most
professionals continue to use LISP because it's more powerful
than its children.
The original version of LISP was called LISP 1. Then came an
improvement, called LISP 1.5 (because it wasn't different enough
from LISP 1 to rate the title ``LISP 2''). Then came a slight
improvement on LISP 1.5, called LISP 1.6. The newest version of
LISP is called Common LISP; it runs on maxicomputers,
minicomputers, and microcomputers.
I'll explain ``typical'' LISP, which is halfway between LISP
1.6 and Common LISP.
Typical LISP uses these symbols:
BASIC LISP
5+2 (PLUS 5 2)
5-2 (DIFFERENCE 5 2)
5*2 (TIMES 5 2)
5/2 (QUOTIENT 5 2)
5^2 (EXPT 5 2)
"LOVE"'LOVE Older versions say: (QUOTE LOVE)
If you want the computer to add 5 and 2, just type:
(PLUS 5 2)
When you press the ENTER key at the end of that line, the
computer will print the answer. (You do not have to say PRINT or
any other special word.) The computer will print:
7
If you type ___
(PLUS 1 3 1 1)
the computer will add 1, 3, 1, and 1 and print:
6
If you type ___
(DIFFERENCE 7 (TIMES 2 3))
the computer will find the difference between 7 and 2*3 and
print:
1
If you type ___
'LOVE
the computer will print:
LOVE
Notice that you must type an apostrophe before LOVE but must not
type an apostrophe afterwards. The apostrophe is called a single
quotation mark (or a quote).
You can put a quote in
front of a word (such as 'LOVE) or in front of a parenthesized
list of words, such as:
'(LAUGH LOUDLY)
That makes the computer print:
(LAUGH LOUDLY)
LISP 1, LISP 1.5, and
LISP 1.6 don't understand the apostrophe. On those old versions
of LISP, say (QUOTE LOVE) instead of 'LOVE, and say (QUOTE (LAUGH
LOUDLY)) instead of '(LAUGH LOUDLY).
The theory of lists LISP
can handle lists. Each list must begin and end with a
parenthesis. Here's a list of numbers: (5 7 4 2). Here's a list
of words: (LOVE HATE WAR PEACE DEATH).
Here's a list of numbers
and words: (2 WOMEN KISS 7 MEN). That list has five items: 2,
WOMEN, KISS, 7, and MEN.
Here's a list of four
items: (HARRY LEMON (TICKLE MY TUBA TOMORROW AT TEN) RUSSIA). The
first item is HARRY; the second is LEMON; the third is a list;
the fourth is RUSSIA.
In a list, the first
item is called the CAR, and the remainder of the list is called
the CDR (pronounced ``could er'' or ``cudder'' or ``coo der'').
For example, the CAR of (SAILORS DRINK WHISKEY) is SAILORS, and
the CDR is (DRINK WHISKEY).
To make the computer
find the CAR of (SAILORS DRINK WHISKEY), type this:
(CAR '(SAILORS DRINK WHISKEY))
The computer will print:
SAILORS
If you type ___
(CDR '(SAILORS DRINK WHISKEY))
the computer will print:
(DRINK WHISKEY)
If you type ___
(CAR (CDR '(SAILORS DRINK WHISKEY)))
the computer will find the CAR of the CDR of (SAILORS DRINK
WHISKEY). Since the CDR of (SAILORS DRINK WHISKEY) is (DRINK
WHISKEY), whose CAR is DRINK, the computer will print:
DRINK
You can insert an extra
item at the beginning of a list, to form a longer list. For
example, you can insert MANY at the beginning of (SAILORS DRINK
WHISKEY), to form (MANY SAILORS DRINK WHISKEY). To do that, tell
the computer to CONStruct the longer list, by typing:
(CONS 'MANY '(SAILORS DRINK WHISKEY))
The computer will print:
(MANY SAILORS DRINK WHISKEY)
Notice that CONS is the
opposite of CAR and CDR. The CONS combines MANY with (SAILORS
DRINK WHISKEY) to form (MANY SAILORS DRINK WHISKEY). The CAR and
CDR break down (MANY SAILORS DRINK WHISKEY), to form MANY and
(SAILORS DRINK WHISKEY).
Variables To make X stand for the number 7, say:
(SETQ X 7)
Then if you say ___
(PLUS X 2)
the computer will print 9.
To make Y stand for the word LOVE, say:
(SETQ Y 'LOVE)
Then if you say ___
Y
the computer will say:
LOVE
To make STOOGES stand for the list (MOE LARRY CURLEY), say:
(SETQ STOOGES '(MOE LARRY CURLEY))
Then if you say ___
STOOGES
the computer will say:
(MOE LARRY CURLEY)
To find the first of the STOOGES, say:
(CAR STOOGES)
The computer will say:
MOE
Your own functions You can define your own functions. For
example, you can define (DOUBLE X) to be 2*X, by typing this:
(DEFUN DOUBLE (X)
(TIMES 2 X)
)
Then if you say ___
(DOUBLE 3)
the computer will print:
6
REPEAT Let's define REPEAT to be a function, so that (REPEAT
'LOVE 5) is (LOVE LOVE LOVE LOVE LOVE), and (REPEAT 'KISS 3) is
(KISS KISS KISS), and (REPEAT 'KISS 0) is ().
If N is 0, we want (REPEAT X N) to be ().
If N is larger than 0, we want (REPEAT X N) to be a list of N
X's. That's X followed by N-1 more X's. That's the CONS of X with
a list of N-1 more X's. That's the CONS of X with (REPEAT X
(DIFFERENCE N 1)). That's (CONS X (REPEAT X (DIFFERENCE N 1))).
That's (CONS X (REPEAT X (SUB1 N))), since (SUB1 N) means N-1 in
LISP.
You can define the answer to (REPEAT X N) as follows: if N is
), the answer is (); if N is not 0, the answer is (CONS X (REPEAT
X (SUB 1 N))). Here's how to type that definition:
(DEFUN REPEAT (X N)
(COND
((ZEROP N) ())
(T (CONS X (REPEAT X (SUB1 N))))
)
)
The top line says you're going to DEfine a FUNction called REPEAT
(X N). The next line says the answer depends on CONDitions. The
next line gives one of those conditions: if N is ZERO, the answer
is (). The next line says: otherwise, the value is (CONS X
(REPEAT X (SUB1 N))). The next line closes the parentheses opened
in the second line. The bottom line closes the parentheses opened
in the top line.
Then if you type ___
(REPEAT 'LOVE 5)
the computer will print:
(LOVE LOVE LOVE LOVE LOVE)
The definition is almost
circular: the definition of REPEAT assumes you already know what
REPEAT is. For example, (REPEAT 'KISS 3) is defined as the CONS
of KISS with the following: (REPEAT 'KISS 2), which is defined as
the CONS of KISS with the following: (REPEAT 'KISS 1), which is
defined as the CONS of KISS with the following (REPEAT 'KISS 1),
which is defined as the CONS of KISS with the following (REPEAT
'KISS 0), which is defined as ().
That kind of definition,
which is almost circular, is called recursive. You can say ``The
definition of REPEAT is recursive'', or ``REPEAT is defined
recursively'', or ``REPEAT is defined by recursion'', or ``REPEAT
is defined by induction'', or ``REPEAT is a recursive function''.
LISP was the first popular language that allowed recursive
definitions.
When the computer uses a
recursive definition, the computer refers to the definition
repeatedly before getting out of the circle. Since the computer
repeats, it's performing a loop. In traditional BASIC and
FORTRAN, the only way to make the computer perform a loop is to
say GO TO or FOR or DO. Although LISP contains a go-to command,
LISP programmers avoid it and write recursive definitions
instead.
ITEM As another example
of recursion, let's define the function ITEM so that (ITEM N X)
is the Nth item in list X, and so that (ITEM 3 '(MANY SAILORS
DRINK WHISKEY)) is the 3rd item of (MANY SAILORS DRINK WHISKEY),
which is DRINK.
If N is 1, (ITEM N X) is
the first item in X, which is the CAR of X, which is (CAR X).
If N is larger than 1,
(ITEM N X) is the Nth item in X. That's the (N-1)th item in the
CDR of X. That's (ITEM (SUB1 N) (CDR X)).
So define (ITEM N X) as
follows: if N is 1, the answer is (CAR X); if N is not 1, the
answer is (ITEM (SUB 1 N) (CDR X)). Here's what to type:
(DEFUN ITEM (N X)
(COND
((ONEP N) ())
(T (ITEM (SUB1 N) (CDR X)))
)
)
If your computer doesn't understand (ONEP N), say (EQUAL 1 N)
instead.
SNOBOL
SNOBOL lets you analyze strings more easily than any other
language. It can handle numbers also.
Simple example Here's a simple SNOBOL program:
A = -2
B = A + 10.6
C = "BODY TEMPERATURE IS 9" B
OUTPUT = "MY " C
END
When you type the program, indent each line except END. Indent
at least one space; you can indent more spaces if you wish. Put
spaces around the symbol =, the symbol +, and other operations.
The first line says A is the integer -2. The next line says B
is the real number 8.6. The next line says C is the string ``BODY
TEMPERATURE IS 98.6''. The next line makes the computer print:
BODY TEMPERATURE IS 98.6
In SNOBOL, a variable's name can be short (like A or B or C) or
as long as you wish. The variable's name can even contain
periods, like this:
NUMBER.OF.BULLIES.I.SQUIRTED
Looping This program's a loop:
FRED OUTPUT = "CAT"
OUTPUT = "DOG" :(FRED)
END
The first line (whose name is FRED) makes the computer print:
CAT
The next line makes the computer print ___
DOG
and then go to FRED. Altogether the computer will print:
CAT
DOG
CAT
DOG
CAT
DOG
etc.
Replacing SNOBOL lets you easily replace one phrase by another.
X = "SIN ON A PIN WITH A DIN"
X "IN" = "UCK"
OUTPUT = X
END
The first line says X is the string ``SIN ON A PIN WITH A DIN''.
The next line says: in X, replace the first ``IN'' by ``UCK''. So
X becomes ``SUCK ON A PIN WITH A DIN''. The next line says the
output is X, so the computer will print:
SUCK ON A PIN WITH A DIN
That program changed the first ``IN'' to ``UCK''. Here's how to
change every ``IN'' to ``UCK'':
X = "SIN ON A PIN WITH A DIN"
X "IN" = "UCK"
X "IN" = "UCK"
X "IN" = "UCK"
OUTPUT = X
END
The first line says X is ``SIN ON A PIN WITH A DIN''. The second
line replaces an ``IN'' by ``UCK'', so X becomes ``SUCK ON A PIN
WITH A DIN''. The next line replaces another ``IN'' by ``UCK'',
so X becomes ``SUCK ON A PUCK WITH A DIN''. The next line
replaces another ``IN'', so X becomes ``SUCK ON A PUCK WITH A
DUCK'', which the
next line prints.
This program does the
same thing:
X = "SIN ON A PIN WITH A DIN"
LOOP X "IN" = "UCK" :S(LOOP)
OUTPUT = X
END
The first line says X is ``SIN ON A PIN WITH A DIN''. The next
line replaces ``IN'' successfully, so X becomes ``SUCK ON A PIN
WITH A DIN''. At the end of the line, the :S(LOOP) means: if
Successful, go to LOOP. So the computer goes back to LOOP. The
computer replaces ``IN'' successfully again, so X becomes ``SUCK
ON A PUCK WITH A DIN'', and the computer goes back to LOOP. The
computer replaces ``IN'' successfully again, so X becomes ``SUCK
ON A PUCK WITH A DUCK'', and the computer goes back to LOOP. The
computer does not succeed. So the computer ignores the :S(LOOP)
and proceeds instead to the next line, which prints:
SUCK ON A PUCK WITH A DUCK
Deleting This program
deletes the first ``IN'':
X = "SIN ON A PIN WITH A DIN"
X "IN" =
OUTPUT = X
END
The second line says to replace an ``IN'' by nothing, so the
``IN'' gets deleted. X becomes ``S ON A PIN WITH A DIN'', which
the computer will print.
This program deletes
every ``IN'':
X = "SIN ON A PIN WITH A DIN"
LOOP X "IN" = :S(LOOP)
OUTPUT = X
END
The computer will print:
S ON A P WITH A D
Counting Let's count how
often ``IN'' appears in ``SIN ON A PIN WITH A DIN''. To do that,
delete each ``IN''; but each time you delete one, increase the
COUNT by 1:
X = "SIN ON A PIN WITH A DIN"
COUNT = 0
LOOP X "IN" = :F(ENDING)
COUNT = COUNT + 1 :(LOOP)
ENDING OUTPUT = COUNT
END
The third line tries to delete an ``IN'': if successful, the
computer proceeds to the next line, which increases the COUNT and
goes back to LOOP; if failing (because no ``IN'' remains), the
computer goes to ENDING, which prints the COUNT. The computer
will print:
3
How SNOBOL developed At
MIT during the 1950's, Noam Chomsky invented a notation called
transformational-generative grammar, which helps linguists
analyze English and translate between English and other
languages. His notation was nicknamed ``linguist's algebra'',
because it helped linguists just as algebra helped scientists. (A
decade later, he became famous for also starting the rebellion
against the Vietnam War.)
Chomsky's notation was
for pencil and paper. In 1957 and 1958, his colleague Victor
Yngve developed a computerized version of Chomsky's notation: the
computerized version was a language called COMIT. It was
nicknamed ``linguist's FORTRAN'', because it helped linguists
just as FORTRAN helped engineers.
COMIT manipulated strings of words. In 1962 at Bell Telephone
Laboratories (Bell Labs), Chester Lee invented a variant called
the Symbolic Communication Language (SCL), which manipulated
strings of mathematical symbols instead of words and helped
mathematicians do abstract mathematics.
A team at Bell Labs decided to invent a language similar to
SCL, but easier to learn and including features from COMIT. At
first, they called their new language ``SCL7'', because it
resembled SCL. Then they changed its name to ``SEXI'' (which
stands for String EXpression Interpreter), but the management of
Bell Labs didn't like sex. Then, as a joke, they named it SNOBOL,
using the flimsy excuse that SNOBOL stands for StriNg-Oriented
symBOlic Language.
Cynics jeered that SNOBOL didn't have ``a snowball's chance in
Hell''. But the cynics were wrong, and SNOBOL became popular. It
was used mainly for writing programs that translate between
computer languages. (For example, you could write a SNOBOL
program that translates FORTRAN into BASIC.)
Which is better: COMIT or SNOBOL? People who like Chomsky's
notation (such as linguists) prefer COMIT. People who like
algebra (such as scientists) prefer SNOBOL.
SNOBOL's supporters were more active than COMIT's: they
produced SNOBOL 2, SNOBOL 3, SNOBOL 4, and SNOBOL 4B, taught
SNOBOL to the newest computers, wrote many books about SNOBOL,
and emphasized that SNOBOL can solve any problem about strings,
even if the problem had nothing to do with linguistics. They won:
most people use SNOBOL instead of COMIT, though COMIT might still
make a comeback.
Today, most versions of SNOBOL are named after baseball
pitching methods ___ such as FASBOL, SLOBOL, and SPITBOL.
(SPITBOL stands for SPeedy ImplemenTation of snoBOL.)
APL
APL lets you manipulate lists of
numbers more easily than any other language.
APL uses special characters that
aren't on a normal keyboard.
To compute 8+9, type this:
8+9
Notice the line is indented. Whenever it's your turn to type, the
computer automatically indents the line for you.
When you press the RETURN key at the
end of that line, the computer will print the answer. (You don't
have to say PRINT or any other special word.) The computer will
print:
17
Scalar operators APL uses these
scalar operators:
APL name SymbolMeaning
PLUS A+B add
identity +B same as just B
MINUS A-B subtract
negative -B negative
TIMES AxB multiply
signum xB 1 if B>0; -1 if B<0; 0
if B=0
DIVIDE A÷B divide
reciprocal ÷B 1 divided by B
POWER A*B A raised to the Bth
power; AB
exponential *B e raised to the Bth
power, where e is 2.718281828459045
LOG A*°B logarithm, base A, of B
natural log *°B logarithm, base e, of B
CEILING ┌B B rounded up to an
integer
maximum A┌B A or B, whichever is
larger
FLOOR └B B rounded down to an
integer
minimum A└B A or B, whichever is
smaller
MAGNITUDE │B the absolute value of B
residue A│B the remainder when you
divide A into B; so 4│19 is 3
FACTORIAL !B 1 times 2 times 3 times
4 times . . . times B
combinations A!B how many A-element
subsets you can form from a set of B
ROLL ?B a random integer from 1
to B
deal A?B list of A random
integers, each from 1 to B, no duplicates
PI TIMES °B π times B
circular A°B sin B if A=1arcsinB if
A=-1
square root of 1+B² if A= 4
cos B if A=2arccosB if
A=-2
square root of 1-B² if A= 0
tan B if A=3arctanB if
A=-3
square root of B²-1 if A=-4
sinh B if A=5arcsinhB if
A=-5
cosh B if A=6arccoshB if
A=-6
tanh B if A=7arctanhB if
A=-7
EQUAL A=B 1 if A equals B;
otherwise 0
not equal A=/B 1 if A is not equal to
B;
otherwise 0
LESS A<B 1 if A is less than
B;otherwise 0
less or equal A≤B 1 if A is less than or
equal to B;
otherwise 0
GREATER A>B 1 if A is greater than
B;
otherwise 0
gr. or equal A≥B 1 if A is greater than
or equal to B;
otherwise 0
AND A^B 1 if A and B are both
1;otherwise 0
nand A^~B 1 if A and B are not
both 1;
otherwise 0
OR AvB 1 if A or B is 1;
otherwise 0
nor Av~B 1 if neither A nor B is
1;
otherwise 0
NOT ~B 1 if B is 0;
otherwise 0
To make the symbol *°, type the symbol *, then press the
BACKSPACE key, then type the symbol °.
Order of operations Unlike all other popular languages, APL
makes the computer do all calculations from right to left. For
example, if you type ___
2x3+5
the computer will start with 5, add 3 (to get 8), and then
multiply by 2 (to get 16). The computer will print:
16
In BASIC and most other languages, the answer would be 11
instead.
If you type ___
9-4-3
the computer will start with 3, subtract it from 4 (to get 1),
and then subtract from 9 (to get 8). The computer will print:
8
In most other languages, the answer would be 2 instead.
You can use parentheses. Although 9-4-3 is 8, (9-4)-3 is 2.
Compare these examples:
-4+6 is -10
-4+6 is 2
In both examples, the 4 is preceded by a negative sign; but in
the second example, the negative sign is raised, to be as high as
the 4. (To make the raised negative, tap the 2 key while holding
down the SHIFT key. To make a regular negative, tap the + key
while holding down the SHIFT key.) The first example makes the
computer start with 6, add 4 (to get 10), and then negate it (to
get -10). The second example makes the computer start with 6 and
add -4, to get 2.
Double precision APL is super-accurate. It does all
calculations by using double precision.
Variables You can use variables:
X
X+2
The first line says X is 3. The second line makes the computer
print X+2. The computer will print:
5
A variable's name can be long: up to 77 letters and digits. The
name must begin with a letter.
Vectors A variable can stand for a list of numbers:
Y 2 8
Y+1
The first line says Y is the vector 5 2 8. The next line makes
the computer add 1 to each item and print:
6 3 9
This program prints the same answer:
5 2 8+1
The computer will print:
6 3 9
This program prints the same answer:
1+5 2 8
You can add a vector to another
vector:
A 2.1 6
B 2.8 -7
A+B
The computer will add 5 to 3, and 2.1 to 2.8, and 6 to -7, and
print:
8 4.9 -1
This program prints the same answer:
5 2.1 6+3 2.8 -7
This program prints the same answer:
A 2.1 6
B 2.8 -7
CA+B
C
Here's something different:
X 2 3
+/X
The first line says X is the vector 4 2 3. The next line makes
the computer print the sum, 9.
This program prints the same answer:
Y+/4 2 3
Y
You can combine many ideas on the
same line, but remember that the computer goes from right to
left:
219-1 4 3+6x+/5 1 3x2 4 7
The computer will start with 2 4 7, multiply it by 5 1 3 (to get
10 4 21), find the sum (which is 35), multiply by 6 (to get 210),
add 1 4 3 (to get 211 214 213), and then subtract from 219 (to
get 8 5 6). The computer will print:
8 5 6
Each of APL's scalar operators works
like addition. Here are examples:
2 4 10x3 7 9 is 6 28 90
÷2 4 10 is .5 .25 .1
-2 4 10 is -2 -4 -10
x/2 4 10 is 2x4x10, which is 80
-/9 5 3 is 9-5-3, which is 7 (since
the computer works from right to left)
└/6.1 2.7 4.9 is 6.1└2.7└4.9, which is 2.7
(since └ means minimum)
└6.1 2.7 4.9 is └6.1 then └2.7 then └4.9,
which is 6 2 4 (since └ means floor)
Vector operators Here are vector
operators; the examples assume V is 8 5 6:
APL name Symbol Value Reason
SHAPE pV 3 V has 3 items
reshape 7pV 8 5 6 8 5 6 8make 7
items from V
REVERSE °│V 6 5 8 reverse V
rotate 1°│V 5 6 8 rotate V, by
beginning after the 1st item
GENERATE i3 1 2 3 count up to 3
index of Vi5 2 in V, find 5;
it's the 2nd item
TAKE 2V 8 5 the first 2
items from V
drop 2V 6 omit the first
two items from V
SUBSCRIPT V[2] 5 V's 2nd item
catenate V,9 4 8 5 6 9 4V followed by
9 4
COMPRESS 1 0 1/V 8 6 take part of
V, using this pattern: take, omit, take
expand 1 0 0 1 1\V8 0 0 5 6insert
zeros into V, using this pattern:
item, 0, 0,
item, item
GRADE UP ■│V 2 3 1 here are V's
numbers in increasing order:
5 (V's 2nd
number), 6 (V's 3rd), 8 (V's 1st)
grade down ■│V 1 3 2 here are V's
numbers in decreasing order:
8 (V's 1st
number), 6 (V's 3rd), 5 (V's 2nd)
DECODE 10┴V 856 8, times 10,
plus 5, times 10, plus 6
encode 10┬8568 5 6 opposite of
decode
MEMBER 5εV 1 search for 5
in V (1=found, 0=missing)
Love or hate? Some programmers love
APL, because its notation is brief. Other programmers hate it,
because its notation is hard for a human to read. The haters are
winning, and the percentage of programmers using APL is
decreasing.
LOGO
LOGO began in 1967, during an evening at Dan Bobrow's home in
Belmont, Massachusetts.
Dan had gotten his Ph.D. from MIT and was working for a company
called Bolt, Beranek, and Newman (BBN). In his living room were
three of his colleagues from BBN (Wally Feurzeig, Cynthia
Solomon, and Dick Grant) and an MIT professor: Seymour Papert.
BBN had tried to teach young kids how to program by using BBN's
own language (TELCOMP), which was a variation of JOSS. BBN had
asked Professor Seymour Papert for his opinion. The group was all
gathered in Dan's house to hear Seymour's opinion.
Seymour chatted with the group, and the entire group agreed
with Seymour on several points. First, TELCOMP was not a great
language for kids. It placed too much emphasis on mathematical
formulas. The group agreed that instead of struggling with math,
the kids ought to have more fun by programming the computer to
handle strings instead.
The group also agreed that the most sophisticated language for
handling strings was LISP, but that LISP was too complex for
kids.
The group concluded that a new, simplified LISP should be
invented for kids, and that it should be called ``LOGO''.
That's how LOGO began. Professor Seymour Papert was the guiding
light, and all the other members of the group gave helpful input
during the conversation.
That night, after his guests left, Dan went to the terminal in
his bedroom and started programming the computer to understand
LOGO. Specifically, he wrote a LISP program that explained to the
computer how to handle LOGO. That's how LOGO was born.
Work on LOGO continued. The three main researchers who
continued improving LOGO were Seymour (the MIT guru), Wally (from
BBN), and Cynthia (also from BBN). LOGO resembled LISP but
required fewer parentheses.
After helping BBN for a year, Seymour returned to MIT. Cynthia
and several other BBN folks worked with him at MIT's Artificial
Intelligence Laboratory to improve LOGO.
Turtles At first, LOGO
was as abstract and boring as most other computer languages. But
in the spring of 1970, a strange creature walked into the LOGO
lab. It was a big yellow mechanical turtle. It looked like ``half
a grapefruit on wheels'' and had a pen in its belly:
It also had a horn, feelers, and several other fancy attachments.
To use it, you put paper all over the floor and then programmed
it to roll across the paper. As it rolled, the pen in its belly
drew pictures on the paper. The turtle was controlled remotely by
a big computer programmed in LOGO.
Suddenly, LOGO became a
fun language whose main purpose was to control the turtle. Kids
watching the turtle screamed with delight and wanted to learn how
to program it. LOGO became a favorite programming game for kids.
Even kids who were just 7 years old started programming in LOGO.
Those kids were barely old enough to read, but reading and
writing were not prerequisites for learning how to program in
LOGO. All the kids had to know was that ``FD 3'' made the turtle
go forward 3 steps, and ``RT 30'' made the turtle turn to the
right 30 degrees.
As for the rest of LOGO
___ all that abstract stuff about strings and numbers and
LISP-like lists ___ the kids ignored it. They wanted to use just
the commands ``FD'' and ``RT'' that moved the turtle.
The U.S. Government's
National Science Foundation donated money, to help MIT improve
LOGO further. Many kids came into the LOGO lab to play with the
turtles.
The turtles were
expensive, and so were the big computers that controlled them. To
let more kids use LOGO, the first problem was to reduce the cost
of the turtle and its controlling computer.
During the early 1970's,
computer screens got dramatically cheaper. To save money, MIT
stopped building mechanical turtles and instead bought cheap
computer screens that showed pictures of turtles. Those pictures
were called ``mock turtles''.
Cheaper computers The
original version of LOGO was done on BBN's expensive weird
computer (the MTS 940). Later versions were done on the PDP-1 (in
1968), the PDP-10 (in 1970), and finally on a cheaper computer:
the PDP-11 minicomputer (in 1972).
At the end of the
1970's, companies such as Apple and Radio Shack began selling
microcomputers, which were even cheaper. MIT wanted to put LOGO
on microcomputers but ran out of money to pay for the research.
Texas Instruments (TI)
came to the rescue. . . .
TI LOGO TI agreed to pay MIT to research how to put LOGO on
TI's microcomputers (the TI-99/4 and the TI-99/4A).
TI and MIT thought the job would be easy, since MIT had already
written a PASCAL program that made the computer understand LOGO,
and since TI had already written a version of PASCAL for the CPU
chip inside the TI-99/4. Initially, MIT was worried because the
PASCAL program running on MIT's PDP-10 computer handled LOGO too
slowly; but TI claimed TI's PASCAL was faster than the PDP-10's
and that LOGO would therefore run fast enough on the TI.
TI was wrong. TI's PASCAL couldn't make LOGO run fast enough,
and TI's PASCAL also required too much RAM. So TI had to take
MIT's research (on the PDP-10) and laboriously translate it into
TI's assembly language, by hand.
The hand translation went slower that TI expected. TI became
impatient and took a short-cut: it omitted parts of LOGO, such as
decimals. TI began selling its version of LOGO, which understood
just integers.
MIT Apple LOGO After TI started selling its LOGO, the MIT group
invented a version of LOGO for the Apple. The Apple version
included decimals. But alas, the Apple version omitted
``sprites'' (which are animated creatures that carry objects
across the screen) because Apple's hardware couldn't handle
sprites fast enough. (TI's hardware was fancier and did handle
sprites.)
MIT wanted to sell the Apple version to schools since more
schools owned Apples than TI computers. But if MIT were to make
lots of money from selling the Apple version, MIT might get into
legal trouble, since MIT was supposed to be non-profit. And
anyway, who ``owned'' LOGO? Possible contenders were:
MIT, which did most of the research
BBN, which trademarked the name ``LOGO'' and did the early
research
Uncle Sam, whose National Science Foundation paid for much
research
TI, which also paid for much research
Eventually, MIT solved the legal problems and sold the rights
for ``MIT Apple LOGO'' to two companies: Krell and Terrapin.
Krell was strictly a marketing company. It sold MIT Apple LOGO
to schools but made no attempt to improve LOGO further.
Terrapin, on the other hand, was a research organization that
had built mechanical turtles for several years. Terrapin hired
some MIT graduates to improve LOGO further.
LCSI versus competitors
Back when MIT was asking its lawyers to determine who owned Apple
LOGO, a group of MIT's faculty and students became impatient. The
group, headed by Cynthia Solomon (one of the original inventors
of LOGO), left MIT and formed a company called LOGO Computer
Systems Incorporated (LCSI). That company invented its own
version of LOGO for the Apple.
LCSI became quite
successful. Apple, IBM, Atari, and Microsoft all hired LCSI to
write versions of LOGO. Commodore hired Terrapin instead.
Today, if you have an
Apple 2c (or 2e or 2+), you can buy either the official Apple
LOGO (sold by Apple Computer Inc. and created by LCSI), or
``Terrapin LOGO for the Apple'' (sold by Terrapin), or the
original ``MIT LOGO for the Apple'' (sold by Krell).
Krell is becoming less
popular. That leaves just two major players: Terrapin and LCSI.
Generally speaking, LCSI's versions of LOGO are daring ___ LCSI
tried wild experiments ___ while Terrapin's versions of LOGO are
conservative ___ closer to the MIT original.
The two companies have
different styles. Terrapin is small and friendly and charges very
little. LCSI is large, charges more, and is often rude. Terrapin
gives more help to customers on the phone than LCSI.
Recently, Terrapin has
had financial difficulties and moved to Maine.
LOGO versus BASIC Most
of LOGO's designers hate BASIC. They believe BASIC should be
eliminated from schools altogether.
They believe LOGO is
easier to learn than BASIC, and that LOGO encourages a kid to be
more creative. They also believe that LOGO leads the kid to think
in a more organized fashion than BASIC. They also argue that
since LOGO is best for little kids, and since switching languages
is difficult, the kids should continue using LOGO until they
graduate from high school and should never use BASIC.
That argument is wrong.
It ignores the fact that a knowledge of BASIC is essential to
surviving in our computerized society. Today, most programs are
still written in BASIC, not LOGO, because BASIC consumes less RAM
and because BASIC's newest versions contain many practical
features for business and science and graphics that LOGO lacks.
Another advantage of
BASIC over LOGO is that LOGO suffers from awkward notation. For
example, in BASIC you can type a formula such as ___
A=B+C
but in LOGO you must type:
MAKE "A :B+:C
Notice how ugly the LOGO command looks! Notice you must put a
quotation mark before the A but must not but a quotation mark
afterwards! And look at those frightful colons! Anybody who
thinks such notation is great for kids is a fool.
Extensible One of the
nicest things about LOGO is that you can change it and turn it
into your own language! That's because LOGO lets you invent your
own commands and add them to the LOGO language. A language (such
as LOGO) that lets you invent your own commands is called an
extensible language. Although some earlier languages (such as
LISP) were extensible also, LOGO is more extensible and more
pleasant.
FORTH
Like LOGO, FORTH is extensible. But FORTH has two advantages
over LOGO:
1. FORTH consumes less memory. You can easily run FORTH on a
computer having just 8K of RAM.
2. FORTH runs faster. The computer handles FORTH almost as fast
as assembly language.
Since FORTH is extensible and consumes so little of the
computer's memory and time, professional programmers use it
often. Famous programs written in FORTH include Easywriter (which
is a word-processing program for the Apple and the IBM Personal
Computer), Valdocs (which is the operating system for Epson's
first computer), and Rapid File (an easy-to-learn data-management
system developed by Miller Microcomputer Systems and sold by
Ashton-Tate).
Unfortunately, the original versions of Easywriter and Valdocs
contained many bugs, but that's because their programmers were
careless.
In FORTH, if you want to add 2 and 3 (to get 5) you do not type
2+3. Instead, you must type:
2 3 +
The idea of putting the plus sign afterwards (instead of in the
middle) is called postfix notation. The postfix notation (2 3 +)
has two advantages over infix notation (2+3): the computer
handles postfix notation faster, and you never need to use
parentheses for ``order of operations''. On the other hand,
postfix notation seems inhuman: it's hard for a human to read.
Like FORTH, Hewlett-Packard pocket calculators use postfix
notation. So if you've already had experience with a